using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using DAL;
using DTO;
namespace BUS
{
   public class tbTinhTrangDealBUS
    {
       public static void Insert(tbTinhTrangDeal tinhtrangdeal)
        {
            tbTinhTrangDealDAL ttdDAL = new tbTinhTrangDealDAL();
            ttdDAL.Insert(tinhtrangdeal);
        }
       public static void Update(tbTinhTrangDeal tinhtrangdeal)
        {
            tbTinhTrangDealDAL ttdDAl = new tbTinhTrangDealDAL();
            ttdDAl.Update(tinhtrangdeal);
        }
        public static void Delete(int iD)
        {
            tbTinhTrangDealDAL ttdDAl = new tbTinhTrangDealDAL();
            ttdDAl.Delete(iD);
        }
       public static tbTinhTrangDealCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbTinhTrangDealDAL ttdDAL = new tbTinhTrangDealDAL();
            return ttdDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
       public static tbTinhTrangDealCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbTinhTrangDealDAL ttdDAL = new tbTinhTrangDealDAL();
            return ttdDAL.Get(cri.Criter, 0, 0, tbTinhTrangDealColumns.mattdeal.ToString(), OrderDirection.ASC.ToString(), out total);
        }
       public static tbTinhTrangDeal GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbTinhTrangDealColumns.mattdeal.ToString(), Condition.EQUAL, iD);
            tbTinhTrangDealDAL ttdDAL = new tbTinhTrangDealDAL();
            tbTinhTrangDealCollection ttdCollection = ttdDAL.Get(cri.Criter, 0, 0, tbTinhTrangDealColumns.mattdeal.ToString(), OrderDirection.ASC.ToString(), out total);
            if (ttdCollection.Count > 0)
                return ttdCollection[0];
            return null;
        }
       public static tbTinhTrangDealCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbTinhTrangDealDAL ttdDAL = new tbTinhTrangDealDAL();
            return ttdDAL.Get(cri.Criter, 1, number, tbTinhTrangDealColumns.mattdeal.ToString(), OrderDirection.DESC.ToString(), out total);
        }
       public static tbTinhTrangDealCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbTinhTrangDealDAL ttdDAL = new tbTinhTrangDealDAL();
            return ttdDAL.Get(cri.Criter, 1, number, tbTinhTrangDealColumns.mattdeal.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
